package com.atguigu.schedule.service.impl;

import com.atguigu.schedule.service.RecordingConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;

/**
 * 录制配置服务实现
 */
@Service
@Slf4j
public class RecordingConfigServiceImpl implements RecordingConfigService {
    
    @Value("${recording.output-path:/recordings}")
    private String defaultOutputPath;
    
    @Value("${recording.format:mp4}")
    private String defaultFormat;
    
    @Value("${recording.quality:medium}")
    private String defaultQuality;
    
    @Value("${recording.max-duration:86400}")
    private Integer maxDuration;
    
    @Override
    public Map<String, Object> getRecordingConfig() {
        Map<String, Object> config = new HashMap<>();
        config.put("outputPath", defaultOutputPath);
        config.put("format", defaultFormat);
        config.put("quality", defaultQuality);
        config.put("maxDuration", maxDuration);
        return config;
    }
    
    @Override
    public boolean updateRecordingConfig(Map<String, Object> config) {
        try {
            // 这里可以实现配置更新逻辑
            // 比如保存到数据库或配置文件
            log.info("更新录制配置: {}", config);
            return true;
        } catch (Exception e) {
            log.error("更新录制配置失败: {}", e.getMessage());
            return false;
        }
    }
    
    @Override
    public String getRecordingOutputPath() {
        return defaultOutputPath;
    }
    
    @Override
    public String getRecordingFormat() {
        return defaultFormat;
    }
}
